package com.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan(basePackages = "com.demo.mapper")
public class OrdersApp {
    public static void main(String[] args) {
        SpringApplication.run(OrdersApp.class, args);
    }

    // 到IOC容器中注入一个RestTemplate
    //发送REST请求的
    @Bean
    //客户端的负载均衡
    //作用：如果服务提供者有多个，服务消费者去调用哪一个
    //就是可以通过负载均衡的算放绝对调用哪个实例

    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
